package org.dromara.system.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import org.dromara.common.core.domain.R;
import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.system.domain.bo.SysDeptBo;
import org.dromara.system.domain.vo.SysDeptVo;
import org.dromara.system.service.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName EY-SysDeptController
 * @Description org.dromara.system.controller
 * @Author menyj
 * @Date 2025/4/3
 **/
@RestController
public class SysDeptController {

    @Autowired
    private ISysDeptService iSysDeptService;
    @GetMapping("/selectDeptById")
    public SysDeptVo selectDeptById(@RequestParam Long deptId) {
        return iSysDeptService.selectDeptById(deptId);
    }

    @GetMapping("/selectDeptById2")
    public SysDeptVo selectDeptById2(@RequestParam Long deptId) {
        TenantHelper.enableIgnore();
        SysDeptVo sysDeptVo = iSysDeptService.selectDeptById(deptId);
        TenantHelper.disableIgnore();
        return sysDeptVo;
    }

    /**
     * 获取部门列表
     */
//    @SaCheckPermission("system:dept:list")
    @GetMapping("/list")
    public R<List<SysDeptVo>> list(SysDeptBo dept) {
        List<SysDeptVo> depts = iSysDeptService.selectDeptList(dept);
        return R.ok(depts);
    }
}
